// pages/oftenline/oftenline.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    city: '请选择',
    oftenline:[
      { date: '2018-09-13', adss: '西安', adsf: '北京' },
      { date: '2018-09-13', adss: '西安', adsf: '北京' },
      { date: '2018-09-13', adss: '西安', adsf: '北京' },
      { date: '2018-09-13', adss: '西安', adsf: '北京'},
    ]
  },
  changecity: function (cityName, type) {
    if (type == 0) {
      console.log("出发城市" + cityName)
      this.setData({
        city: cityName
      })
    }
    else if (type == 1) {
      console.log("送货城市" + cityName)
      this.setData({
        city1: cityName
      })
    }
  },
  // 选择地址
  chose_city: function (e) {
    var type = e.currentTarget.dataset.type;
    var that = this;
    wx.navigateTo({
      url: '../address/address?type=' + type,
    })
  },
  //添加常跑路线
  addoftenline(){
    app.navTo('../addoftenline/addoftenline')
  },
  start_delete(e){
    console.log(e)
    var index = e.currentTarget.dataset.index;
    var oftenline = this.data.oftenline;
    oftenline.splice(index, 1);  
    wx.showToast({
      title: '删除常跑路线',
      duration: 3000,
      icon: 'success',
    })
    this.setData({
      oftenline: oftenline
    }); 
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})